import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  //路由重定向
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: Home
  },
  {
    path: '/rankinglist:id?',
    name: 'RankingList',
    component: () => import(/* webpackChunkName: "paihang" */ '../views/RankingList.vue')
  },
  {
    path: '/mymusic',
    name: 'MyMusic',
    component: () => import(/* webpackChunkName: "MyMusic" */ '../views/MyMusic.vue')
  },

  {
    path: '/songlist',
    name: 'SongList',
    component: () => import(/* webpackChunkName: "SongList" */ '../views/SongList.vue')
  },
  {
    path: '/anchorstation',
    name: 'AnchorStation',
    component: () => import(/* webpackChunkName: "AnchorStation" */ '../views/AnchorStation.vue')
  },
  {
    path: '/singer',
    name: 'Singer',
    component: () => import(/* webpackChunkName: "Singer" */ '../views/Singer.vue')
  },
  {
    path: '/newcd',
    name: 'NewCD',
    component: () => import(/* webpackChunkName: "NewCD" */ '../views/NewCD.vue')
  },
]

// 把这段代码直接粘贴到router/index.js中的Vue.use(VueRouter)之前
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
  return originalPush.call(this, location).catch(err => { })
};
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
